package com.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.TalkKiaraDao;
import com.entity.TalkKiara;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Random;

/**
 * @author WZ
 * @version 1.0
 * @date 2021/10/1 15:01
 */
@Service
public class TalkKiaraServiceImpl extends ServiceImpl<TalkKiaraDao,TalkKiara> implements TalkKiaraService {
	@Resource
	private TalkKiaraDao talkKiaraDao;

	public TalkKiara randomKiara(){
		TalkKiara talkKiara=new TalkKiara();
		List<TalkKiara> talkKiaraList=this.list(new LambdaQueryWrapper<TalkKiara>().eq(TalkKiara::getUsed,2));
		Integer randomNumer=(int)(Math.random()*talkKiaraList.size());
		talkKiara=talkKiaraList.get(randomNumer);
		return talkKiara;

	}

}
